﻿using System;
using System.IO;
using System.Globalization;
using Microsoft.Win32;
using System.Collections.Generic;
using System.Text;
using Microsoft.MediaCenter;

namespace McePicasa
{
    //Static global variables
    class Global
    {
        private Global() { } //For FxCop only

        public static void Init()
        {
            int screenWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
            if (screenWidth <= 1024)
                Imgmax = "1024";
            else if (screenWidth <= 1280)
                Imgmax = "1280";
            else
                Imgmax = "1600";

            string installLocation = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\Microsoft\McePicasa", @"InstallLocation", null) as string;
            if (installLocation == null)
                installLocation = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\McePicasa", @"InstallLocation", null) as string;

            if (installLocation != null && File.Exists(installLocation + @"\Picasa.Logo.png"))
            {
                iconImagePath = String.Format(CultureInfo.CurrentCulture, "file://{0}\\Picasa.Logo.png", installLocation);
            }
            else
            {
                iconImagePath = @"http://www.google.com/intl/en_ALL/images/logo.gif";
                Log.LogIt("DialogIconImagePath: Cannot access registry key or no registry key found!");
            }

            if (installLocation != null && File.Exists(installLocation + @"\Flickr.Logo.png"))
            {
                iconImagePathFlickr = String.Format(CultureInfo.CurrentCulture, "file://{0}\\Flickr.Logo.png", installLocation);                
            }
            else
            {
                iconImagePathFlickr = @"http://l.yimg.com/g/images/flickr_logo_gamma.gif.v35314.14";
                Log.LogIt("DialogIconImagePath: Cannot access registry key or no registry key found!");                
            }
        }        

        public static string Imgmax
        {
            get { return imgmax; }
            set { imgmax = value; }
        }

        public static void MsgBox(string message, int timeout)
        {
            Application.Current.MediaCenterEnvironment.Dialog(
                message,
                "McePicasa",
                DialogButtons.Ok, timeout, true);
        }

        public static void MsgBox(string message, int timeout, bool modal)
        {
            Application.Current.MediaCenterEnvironment.Dialog(
                message,
                "McePicasa",
                DialogButtons.Ok, timeout, modal);
        }

        public static string IconImagePath
        {
            get { return Global.iconImagePath; }
            //set { Global.iconImagePath = value; }
        }

        public static string IconImagePathFlickr
        {
            get { return Global.iconImagePathFlickr; }
            //set { Global.iconImagePathFlickr = value; }
        }

        private static string imgmax = "1024";
        private static string iconImagePath;
        private static string iconImagePathFlickr;
    }
}
